package com.registration.controller;

import com.registration.entity.ResultEntity;
import com.registration.entity.YlRegistrationRecord;
import com.registration.entity.utilentity.UEeRegistrationReconrdController;
import com.registration.server.RegistrationRecordServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 挂号记录
* */
@RestController
@RequestMapping("/registration")
public class RegistrationRecordController {

    @Autowired
    RegistrationRecordServer registrationRecordServer;

    //第一步添加挂号记录，（数据存入redis，等待支付）
    @RequestMapping("/addRecord")
    public ResultEntity<String> addRecord(@RequestBody YlRegistrationRecord ylRegistrationRecord){
        String data = registrationRecordServer.addRecord(ylRegistrationRecord);
        return new ResultEntity<>(200,"成功",data);
    }
    //第二步确认挂号记录，（修改数据状态，确认支付）
    @RequestMapping("/confirmRecord")
    public ResultEntity<String> confirmRecord(@RequestBody UEeRegistrationReconrdController uEe){
        registrationRecordServer.confirmRecord(uEe);
        return new ResultEntity<>(200,"成功","data");
    }

    @RequestMapping("/findAll")
    public ResultEntity<List<YlRegistrationRecord>> findAll(@RequestBody YlRegistrationRecord ylRegistrationRecord){
        return new ResultEntity<List<YlRegistrationRecord>>(200,"查询成功",registrationRecordServer.findAll(ylRegistrationRecord));
    }
    //未支付接口
    @RequestMapping("/toBePaid")
    public ResultEntity<YlRegistrationRecord> toBePaid(@RequestBody UEeRegistrationReconrdController uEe){
        return new ResultEntity<YlRegistrationRecord>(200,"ok",registrationRecordServer.toBePaid(uEe));
    }

    //未就诊接口
    @GetMapping("/unSeeDoctor")
    public ResultEntity<List<YlRegistrationRecord>> unSeeDoctor(){
        return new ResultEntity<List<YlRegistrationRecord>>(200,"查询成功",registrationRecordServer.unSeeDoctor());
    }

    //已就诊接口
    @GetMapping("/endSeeDoctor")
    public ResultEntity<List<YlRegistrationRecord>> endSeeDoctor(){
        return new ResultEntity<List<YlRegistrationRecord>>(200,"查询成功",registrationRecordServer.endSeeDoctor());
    }

    //未支付订单
    @GetMapping("/unPaid")
    public ResultEntity<List<YlRegistrationRecord>> unPaid(){
        return new ResultEntity<List<YlRegistrationRecord>>(200,"查询成功",registrationRecordServer.unPaid());
    }

}
